package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.AdministrativeOfficeDTO;
import com.hksj.Intelligentmanagement.service.AdministrativeOfficeService;
import com.hksj.Intelligentmanagement.vo.AdministrativeOfficeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName AdministrativeOfficeController
 * @Description TODO
 * @Author @陈章
 * @Date 2023/3/31 17:54
 * @Version 1.0
 */
@Api(tags = "科室信息")
@RestController
@RequestMapping("/api/administrativeOffice")
public class AdministrativeOfficeController {

    @Autowired
    private AdministrativeOfficeService administrativeOfficeService;


    @ApiOperation(value = "科室新增")
    @PostMapping("/addAdministrativeOffice")
    public Result addAdministrativeOffice(@RequestBody AdministrativeOfficeDTO administrativeOfficeDTO) {
        administrativeOfficeService.addAdministrativeOffice(administrativeOfficeDTO);
        return Result.ok();
    }


    @ApiOperation(value = "科室删除")
    @GetMapping("/delAdministrativeOffice")
    public Result delAdministrativeOffice(String id) {
        administrativeOfficeService.dellAdministrativeOffice(id);
        return Result.ok();
    }

    @ApiOperation(value = "科室查询")
    @GetMapping("/selectAdministrativeOffice")
    public Result selectAllAdministrativeOffice() {
        List<AdministrativeOfficeVo> list=administrativeOfficeService.selectAdministrativeOffice();
        return Result.ok(list);
    }


    @ApiOperation(value = "科室修改")
    @PostMapping("/upAdministrativeOffice")
    public Result upAdministrativeOffice(@RequestBody AdministrativeOfficeDTO administrativeOfficeDTO) {
        administrativeOfficeService.upAdministrativeOffice(administrativeOfficeDTO);
        return Result.ok();
    }


    @ApiOperation(value = "修改科室启用状态")
    @GetMapping("/upOfficeStatus")
    public Result upOfficeStatus(String id,String status) {
        administrativeOfficeService.upOfficeStatus(id,status);
        return Result.ok();
    }
}
